package com.zy.ivideo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@ApiModel(value = "用户实体类",description = "用户实体类")
@Table(name = "s_user")
public class UserEntity {
    public UserEntity() {
    }

    public UserEntity(String username, String password) {
        this.username = username;
        this.password = password;
    }

    /**
     * 主键
     */
    @ApiModelProperty(value = "主键id",position = 16,example = "0")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名",position = 16,example = "xiaohong")
    @Column(nullable = false,unique = true,length = 20)
    private String username;

    /**
     * 登录密码 md5
     */
    @ApiModelProperty(value = "登录密码 md5",position = 16,example = "aabbccddeeffgg")
    @Column(nullable = false,length = 200)
    private String password;

    /**
     * 用户昵称
     */
    @ApiModelProperty(value = "用户昵称",position = 16,example = "小红")
    @Column(length = 100)
    private String nick;

    /**
     * 用户头像
     */
    @ApiModelProperty(value = "用户头像",position = 16,example = "http://xx.com/1.png")
    @Column(length = 100)
    private String headImg;

    @ApiModelProperty(value = "是否作者 0-否 1-是",position = 16,example = "0")
    @Column(name = "isAuthor",columnDefinition = "int DEFAULT 0 COMMENT '是否作者 0-否 1-是'")
    private Integer isAuthor;

    /**
     * 创建日期
     */
    @ApiModelProperty(value = "创建日期",position = 16,example = "2024-01-01 00:00:00")
    @CreatedDate
    @Column()
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date ctime;

    /**
     * Token
     */
    @ApiModelProperty(value = "Token",position = 16,example = "")
    @Transient
    private String token;

    /**
     * 账户id
     */
    @ApiModelProperty(value = "账户id",position = 16,example = "1")
    @Column(length = 8)
    private Integer accountid;
}
